import http from './public'
// 电脑列表
export const getComputer = (params) => {
	console.log('params', params)
	console.log('params.priceGt', params.priceGt)
	if(params.params.sort==1){
		if(params.params.priceGt=='') {
			return http.fetchGet('/Client/Products??OnSale=1&orderByString=CurrentPrice.ascending', params)
		}else {
			return http.fetchGet('/Client/Products?OnSale=1&orderByString=CurrentPrice.ascending'+'&CurrentPrice='+params.params.priceGt+'--'+params.params.priceLte, params)
		}
	}else {
		if(params.params.priceGt=='') {
			return http.fetchGet('/Client/Products?OnSale=1&orderByString=CurrentPrice.descending', params)
		}else {
			return http.fetchGet('/Client/Products?OnSale=1&orderByString=CurrentPrice.descending'+'&CurrentPrice='+params.params.priceGt+'--'+params.params.priceLte, params)
		}
	}
}

// 获取购物车列表
export const getCartList = (params) => {
  return http.fetchGet('/Client/Carts', params)
}
// 加入购物车
export const addCart = (params) => {
  return http.fetchPost('/client/Carts', params)
}
// 批量加入购物车
export const addCartBatch = (params) => {
  return http.fetchPost('/goods/addCartBatch', params)
}
// 删除购物车
export const delCart = (params) => {
  return http.fetchPost('/goods/delCart', params)
}
// 编辑购物车
export const cartEdit = (id, params) => {
return http.fetchPut('/client/Carts/'+id, params)
}
// 全选
export const editCheckAll = (params) => {
  return http.fetchPost('/users/editCheckAll', params)
}
// 删除购物车单个商品
export const cartDel = (params) => {
  return http.fetchDelete('/client/Carts/'+params.productId, params)
}
// 获取用户地址
export const addressList = (params) => {
  return http.fetchGet('/client/Address', params)
}
// 根据id获取用户地址2
export const addressList2 = (params) => {
  return http.fetchGet('/client/Address/'+params.Id, params)
}

// 修改收货地址
export const addressUpdate = (params) => {
  return http.fetchPut('/client/Address/'+params.Id, params)
}
// 添加收货地址
export const addressAdd = (params) => {
  return http.fetchPost('/client/Address', params)
}
//设为默认收货地址
export const addressDefault = (Id, params) => {
  return http.fetchPut('/client/Members/'+Id, params)
}
// 删除收货地址
export const addressDel = (params) => {
  return http.fetchDelete('/client/Address/'+params.Id, params)
}
// 生成订单
export const payMent = (params) => {
  return http.fetchPost('/client/Orders', params)
}
//返回支付二位码
export const payMentErWei = (params) => {
  return http.fetchPost('/client/OrderPays', params)
}
// 订单列表
export const orderList = (params) => {
	console.log('params', params)
  return http.fetchGet('/client/Orders?orderByString=UpdateDate.descending&isdelete=0&limit='+params.limit+'&page='+params.page)
}
//根据订单id获取订单信息
export const getOrderDet = (orderId) => {
  return http.fetchGet('/client/Orders?Id='+orderId)
}
// 商品详情
export const productDet = (params) => {
  return http.fetchGet('/goods/productDet', params)
}
// 商品详情2 根据商品id获取商品信息
export const productDet2 = (params) => {
  return http.fetchGet('/Client/Products/'+params)
}
// 删除订单
export const delOrder = (params) => {
  return http.fetchDelete('/client/Orders/'+params)
}
// 取消订单
export const cancelOrder = (orderId, params) => {
  return http.fetchPut('/client/Orders/'+orderId, params)
}
// 获取商品规格
export const fetchGuiGeData = (id) => {
  return http.fetchGet('/Client/ProductAttrs?ProductId='+id+'&IsSku='+1)
}
// 获取商品规格
export const getSkuId = (params) => {
  return http.fetchPost('/base/sku', params)
}
// 根据skuId获取商品规格值
export const getSkuVal = (id, params) => {
	console.log('id', id)
  return http.fetchGet('/client/SkuItems/'+id, params)
}
// 根据skuId获取商品规格值
export const paySuccess = (OrderId, params) => {
  return http.fetchGet('/client/OrderPays/queryOrder?OrderId='+OrderId, params)
}
//评价订单
export const rateOrder = (params) => {
  return http.fetchPost('/client/Comments', params)
}
//获取验证码
export const GetSmsCode = (CellPhone, params) => {
  return http.fetchGet('/base/SmsCode/?CellPhone='+CellPhone, params)
}
//根据skuId获取商品类型
export const GetSkuVal = (skuId, params) => {
  return http.fetchGet('/client/Skus/'+skuId, params)
}
//获取商品评价
export const GetComments = (Id, params) => {
  return http.fetchGet('/client/Comments?ProductId='+Id, params)
}
//确定收货
export const SureGetGoods = (Id, params) => {
  return http.fetchPut('/client/Orders/'+Id, params)
}